﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace blackhouse.JavaScript {
    public enum EasingType {
        EaseOutQuad,
        EaseInQuad,
        EaseInOutQuad,
        EaseInCubic,
        EaseOutCubic,
        EaseInOutCubic, 
        EaseInQuart,
        EaseOutQuart,
        EaseInOutQuart,
        EaseInQuint,
        EaseOutQuint,
        EaseInOutQuint,
        EaseInSine,
        EaseOutSine,
        EaseInOutSine,
        EaseInExpo,
        EaseOutExpo,
        EaseInOutExpo,
        EaseInCirc,
        EaseOutCirc,
        EaseInOutCirc,
        EaseInElastic,
        EaseOutElastic,
        EaseInOutElastic,
        EaseInBack,
        EaseOutBack,
        EaseInOutBack,
        EaseInBounce,
        EaseOutBounce,
        EaseInOutBounce
    }

    public static class ExtendEasingType {
        public static string ConvertJsReadable(this EasingType type) {
            string sType = type.ToString();
            return sType[0].ToString().ToLower() + sType.Substring(1);
        }

        public static string BuildJavaScriptEasingArray(string jsArrayName) {
            List<string> jsElements = new List<string>();
            jsElements.Add("var " + jsArrayName + " = new Array();");
            foreach (EasingType et in Enum.GetValues(typeof(EasingType))) {
                jsElements.Add(string.Format("{0}.push('{1}');", jsArrayName, et.ConvertJsReadable()));
            }
            return string.Join(Environment.NewLine, jsElements.ToArray());
        }

    }
}